package com.example.utils;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.DispatcherType;

/**
 * @author zhy
 * @version 1.0.0
 * @ClassName FilterRegisterConfiguration.java
 * @Description TODO
 * @createTime 2021年08月05日 14:57:00
 */
@Configuration
public class FilterRegisterConfiguration {

    @Bean
    public FilterRegistrationBean<ParamsFilter> paramsFilterFilterRegistrationBean() {
        FilterRegistrationBean<ParamsFilter> registrationBean = new FilterRegistrationBean<ParamsFilter>();
        registrationBean.setDispatcherTypes(DispatcherType.REQUEST);
        registrationBean.setFilter(new ParamsFilter());
        registrationBean.addUrlPatterns("/*");
        registrationBean.setName("paramsFilter");
        registrationBean.setOrder(Integer.MAX_VALUE - 1);
        return registrationBean;
    }
}
